/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package IHM;

import TouristManagement.InfoSite;
import TouristManagement.InfoTraffic;
import TouristManagement.Client.Tourist.TouristClient;

import java.awt.CardLayout;
import java.util.Map;
import javax.swing.JOptionPane;

/**
 *
 * @author HaBL
 */
public final class TouristeIHM extends javax.swing.JFrame {

    /**
     * Creates new form Touriste
     */
    private TouristClient tct ;
    public TouristeIHM() {
        initComponents();
        init();
 
    }
    
    
    public void init(){
        TouristeIHM.Lbl5_BacKToPre.setVisible(false);
        tct = new TouristClient();
        tct.initServer();
        Map<Short,String> mp;
        mp= tct.getListSite();
        Cb2_SiteVisite.addItem("...");
        for (Short i:mp.keySet()){
            Cb2_SiteVisite.addItem(mp.get(i));   
        }
      
    }
    
    public void consulterSites(){
         //Consulter 5 sites:
        InfoSite[] infoSite = tct.consultListeSites();        
        String [] nomSite= new String[5];//nom site
        String [] nbVisisiteActuel =new String[5];//affluence courante
        String [] heureOuvert=new String[5];
        String [] heureFerme=new String[5];//horaire fermeture
        String [] nbMaxVisite=new String[5];//nombre max visite
        String [] infoTraff=new String[5];//info traffic
        
        int idInfoSite=0;
        int idResult=0;
        
        //pour afficher au plus 5 sites
        while (idInfoSite<infoSite.length && idResult<5 && infoSite[idInfoSite]!=null) {
        //on en prend que les sites non visités
        	if (!infoSite[idInfoSite].visited) {
        		nomSite[idResult]=infoSite[idInfoSite].siteName;
            	heureOuvert[idResult]= infoSite[idInfoSite].openingHours.hour + "h"+ infoSite[idInfoSite].openingHours.minute + "m" + infoSite[idInfoSite].openingHours.seconde +"s";
            	heureFerme[idResult]= infoSite[idInfoSite].closingHours.hour + "h"+ infoSite[idInfoSite].closingHours.minute + "m" + infoSite[idInfoSite].closingHours.seconde +"s";
            	nbVisisiteActuel[idResult]= String.valueOf(infoSite[idInfoSite].currentNbVisitors);
            	nbMaxVisite[idResult] = String.valueOf(infoSite[idInfoSite].maxNbVisitors);
            	//get info traffic
            	InfoTraffic[] infoTraffic = infoSite[idInfoSite].infosTraffic;
            	for (InfoTraffic info:infoTraffic) {            		
            		if (infoTraff[idResult]!=null) 
            			infoTraff[idResult]= infoTraff[idResult]+"    - " + info.nameSystem + " : " + info.trafficTime + " min"+ "<br/>";
            		else 
            			infoTraff[idResult]= "    - " + info.nameSystem + " : " + info.trafficTime + " min"+ "<br/>";
            	}
            	idResult++;            					
            }
            idInfoSite++;
		}
        
        
        String []strResul= new String[5];
        for (int i=0;i<5;i++){
        	if (nomSite[i] != null)
            strResul[i] = "<HTML><b><u>Site:</b></u> "+nomSite[i]+"<br><b><u>Affluence courante: </b></u>"+nbVisisiteActuel[i]+"<br><b><u>Horaire fermeture: </b></u>"+heureFerme[i]+"<br><b><u>Durée du trajet: </b></u><br>"+infoTraff[i]+"</HTML>";            
        }
        
        this.Lbl5_1erSite.setText(strResul[0]);
        this.Lbl5_2emeSite.setText(strResul[1]);
        this.Lbl5_3emeSite.setText(strResul[2]);
        this.Lbl5_4emeSite.setText(strResul[3]);
        this.Lbl5_5emeSite.setText(strResul[4]);
    }
    

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        MainPanel = new javax.swing.JPanel();
        AcceuilTourist = new javax.swing.JPanel();
        Btn1_NouvClient = new javax.swing.JButton();
        Lbl1_Titre = new javax.swing.JLabel();
        Lbl1_DejaCarte = new javax.swing.JLabel();
        Lbl1_NumTouriste = new javax.swing.JLabel();
        Tf1_NumTouriste = new javax.swing.JTextField();
        Btn1_Connecter = new javax.swing.JButton();
        Lbl1_ImageMain = new javax.swing.JLabel();
        Lbl1_Vide = new javax.swing.JLabel();
        CheckIn = new javax.swing.JPanel();
        Lbl2_Titre = new javax.swing.JLabel();
        Lbl2_NumTourist = new javax.swing.JLabel();
        Lb2_SiteSouhaite = new javax.swing.JLabel();
        Cb2_SiteVisite = new javax.swing.JComboBox();
        Btn2_Entrez = new javax.swing.JButton();
        Btn2_Consulter = new javax.swing.JButton();
        Lbl2_BacktoHome = new javax.swing.JLabel();
        Lbl2_Vide = new javax.swing.JLabel();
        AchatCarteNFC = new javax.swing.JPanel();
        Lbl3_Titre = new javax.swing.JLabel();
        Lbl3_Nom = new javax.swing.JLabel();
        Tf3_Nom = new javax.swing.JTextField();
        Cl3_DateDebut = new com.toedter.calendar.JDateChooser();
        Lbl3_DateDebut = new javax.swing.JLabel();
        Lbl3_DureeValide = new javax.swing.JLabel();
        Cl3_DateFin = new com.toedter.calendar.JDateChooser();
        Btn3_Acheter = new javax.swing.JButton();
        Lbl_BackToHome = new javax.swing.JLabel();
        Lbl3_Vide = new javax.swing.JLabel();
        CheckOut = new javax.swing.JPanel();
        Lbl4_Titre = new javax.swing.JLabel();
        Cb4_Avis = new javax.swing.JComboBox();
        Lbl4_Avis = new javax.swing.JLabel();
        Btn4_Sortie = new javax.swing.JButton();
        Btn4_Consulter = new javax.swing.JButton();
        Lbl4_Vide = new javax.swing.JLabel();
        Consulter5sites = new javax.swing.JPanel();
        Lbl_titre = new javax.swing.JLabel();
        Lbl5_ButtonBackToPre = new javax.swing.JLabel();
        Lbl5_BacKToPre = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel1 = new javax.swing.JPanel();
        Lbl5_1erSite = new javax.swing.JLabel();
        Lbl5_2emeSite = new javax.swing.JLabel();
        Lbl5_3emeSite = new javax.swing.JLabel();
        Lbl5_4emeSite = new javax.swing.JLabel();
        Lbl5_5emeSite = new javax.swing.JLabel();
        Lbl_Vide = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        MainPanel.setLayout(new java.awt.CardLayout());

        AcceuilTourist.setLayout(null);

        Btn1_NouvClient.setText("Nouveau Client");
        Btn1_NouvClient.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Btn1_NouvClientActionPerformed(evt);
            }
        });
        AcceuilTourist.add(Btn1_NouvClient);
        Btn1_NouvClient.setBounds(60, 340, 240, 40);

        Lbl1_Titre.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        Lbl1_Titre.setForeground(new java.awt.Color(255, 255, 255));
        Lbl1_Titre.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        Lbl1_Titre.setText("Bienvenue");
        AcceuilTourist.add(Lbl1_Titre);
        Lbl1_Titre.setBounds(50, 130, 260, 30);

        Lbl1_DejaCarte.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        Lbl1_DejaCarte.setForeground(new java.awt.Color(255, 255, 255));
        Lbl1_DejaCarte.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        Lbl1_DejaCarte.setText("Déjà client. Connectez-vous");
        AcceuilTourist.add(Lbl1_DejaCarte);
        Lbl1_DejaCarte.setBounds(60, 400, 240, 17);

        Lbl1_NumTouriste.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        Lbl1_NumTouriste.setForeground(new java.awt.Color(255, 255, 255));
        Lbl1_NumTouriste.setText("Numéro de touriste");
        AcceuilTourist.add(Lbl1_NumTouriste);
        Lbl1_NumTouriste.setBounds(70, 440, 110, 14);

        Tf1_NumTouriste.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Tf1_NumTouristeActionPerformed(evt);
            }
        });
        AcceuilTourist.add(Tf1_NumTouriste);
        Tf1_NumTouriste.setBounds(190, 430, 110, 30);

        Btn1_Connecter.setText("Connecter");
        Btn1_Connecter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Btn1_ConnecterActionPerformed(evt);
            }
        });
        AcceuilTourist.add(Btn1_Connecter);
        Btn1_Connecter.setBounds(90, 480, 170, 30);

        Lbl1_ImageMain.setIcon(new javax.swing.ImageIcon(getClass().getResource("/util/ZImage.png"))); // NOI18N
        AcceuilTourist.add(Lbl1_ImageMain);
        Lbl1_ImageMain.setBounds(40, 160, 280, 190);

        Lbl1_Vide.setIcon(new javax.swing.ImageIcon(getClass().getResource("/util/ZSmp22.jpg"))); // NOI18N
        AcceuilTourist.add(Lbl1_Vide);
        Lbl1_Vide.setBounds(0, 0, 360, 690);

        MainPanel.add(AcceuilTourist, "AcceuilTourist");

        CheckIn.setLayout(null);

        Lbl2_Titre.setBackground(new java.awt.Color(51, 102, 255));
        Lbl2_Titre.setFont(new java.awt.Font("Aharoni", 1, 24)); // NOI18N
        Lbl2_Titre.setForeground(new java.awt.Color(255, 255, 255));
        Lbl2_Titre.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        Lbl2_Titre.setText("Entrez du site");
        CheckIn.add(Lbl2_Titre);
        Lbl2_Titre.setBounds(60, 150, 240, 30);

        Lbl2_NumTourist.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        Lbl2_NumTourist.setForeground(new java.awt.Color(255, 255, 255));
        Lbl2_NumTourist.setText("Bonjour,");
        CheckIn.add(Lbl2_NumTourist);
        Lbl2_NumTourist.setBounds(50, 220, 260, 20);

        Lb2_SiteSouhaite.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        Lb2_SiteSouhaite.setForeground(new java.awt.Color(255, 255, 255));
        Lb2_SiteSouhaite.setText("Site souhaité de visite");
        CheckIn.add(Lb2_SiteSouhaite);
        Lb2_SiteSouhaite.setBounds(70, 250, 130, 20);

        Cb2_SiteVisite.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Cb2_SiteVisiteActionPerformed(evt);
            }
        });
        CheckIn.add(Cb2_SiteVisite);
        Cb2_SiteVisite.setBounds(110, 280, 130, 30);

        Btn2_Entrez.setText("Entrez du site");
        Btn2_Entrez.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Btn2_EntrezActionPerformed(evt);
            }
        });
        CheckIn.add(Btn2_Entrez);
        Btn2_Entrez.setBounds(80, 340, 190, 30);

        Btn2_Consulter.setText("Consulter la liste de 5 sites");
        Btn2_Consulter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Btn2_ConsulterActionPerformed(evt);
            }
        });
        CheckIn.add(Btn2_Consulter);
        Btn2_Consulter.setBounds(80, 390, 190, 30);

        Lbl2_BacktoHome.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        Lbl2_BacktoHome.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Lbl2_BacktoHomeMouseClicked(evt);
            }
        });
        CheckIn.add(Lbl2_BacktoHome);
        Lbl2_BacktoHome.setBounds(40, 560, 60, 40);

        Lbl2_Vide.setBackground(new java.awt.Color(204, 204, 255));
        Lbl2_Vide.setFont(new java.awt.Font("Aharoni", 1, 24)); // NOI18N
        Lbl2_Vide.setForeground(new java.awt.Color(51, 51, 51));
        Lbl2_Vide.setIcon(new javax.swing.ImageIcon(getClass().getResource("/util/ZSmp22.jpg"))); // NOI18N
        CheckIn.add(Lbl2_Vide);
        Lbl2_Vide.setBounds(0, 0, 360, 690);

        MainPanel.add(CheckIn, "CheckIn");

        AchatCarteNFC.setLayout(null);

        Lbl3_Titre.setFont(new java.awt.Font("Aharoni", 1, 24)); // NOI18N
        Lbl3_Titre.setForeground(new java.awt.Color(255, 255, 255));
        Lbl3_Titre.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        Lbl3_Titre.setText("Acheter la carte NFC");
        AchatCarteNFC.add(Lbl3_Titre);
        Lbl3_Titre.setBounds(50, 150, 260, 40);

        Lbl3_Nom.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        Lbl3_Nom.setForeground(new java.awt.Color(255, 255, 255));
        Lbl3_Nom.setText("Votre nom");
        AchatCarteNFC.add(Lbl3_Nom);
        Lbl3_Nom.setBounds(50, 230, 70, 14);

        Tf3_Nom.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Tf3_NomActionPerformed(evt);
            }
        });
        AchatCarteNFC.add(Tf3_Nom);
        Tf3_Nom.setBounds(120, 220, 180, 30);

        Cl3_DateDebut.setDateFormatString("yyyy-MM-dd");
        Cl3_DateDebut.setMaxSelectableDate(new java.util.Date(253370764863000L));
        Cl3_DateDebut.setMinSelectableDate(new java.util.Date());
        AchatCarteNFC.add(Cl3_DateDebut);
        Cl3_DateDebut.setBounds(160, 270, 140, 30);

        Lbl3_DateDebut.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        Lbl3_DateDebut.setForeground(new java.awt.Color(255, 255, 255));
        Lbl3_DateDebut.setText("Date début valide");
        AchatCarteNFC.add(Lbl3_DateDebut);
        Lbl3_DateDebut.setBounds(50, 280, 100, 14);

        Lbl3_DureeValide.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        Lbl3_DureeValide.setForeground(new java.awt.Color(255, 255, 255));
        Lbl3_DureeValide.setText("Date fin valide");
        AchatCarteNFC.add(Lbl3_DureeValide);
        Lbl3_DureeValide.setBounds(50, 330, 130, 14);

        Cl3_DateFin.setDateFormatString("yyyy-MM-dd");
        Cl3_DateFin.setMinSelectableDate(new java.util.Date());
        AchatCarteNFC.add(Cl3_DateFin);
        Cl3_DateFin.setBounds(160, 320, 140, 30);

        Btn3_Acheter.setText("Acheter");
        Btn3_Acheter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Btn3_AcheterActionPerformed(evt);
            }
        });
        AchatCarteNFC.add(Btn3_Acheter);
        Btn3_Acheter.setBounds(80, 410, 200, 40);

        Lbl_BackToHome.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        Lbl_BackToHome.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Lbl_BackToHomeMouseClicked(evt);
            }
        });
        AchatCarteNFC.add(Lbl_BackToHome);
        Lbl_BackToHome.setBounds(30, 560, 70, 40);

        Lbl3_Vide.setIcon(new javax.swing.ImageIcon(getClass().getResource("/util/ZSmp22.jpg"))); // NOI18N
        AchatCarteNFC.add(Lbl3_Vide);
        Lbl3_Vide.setBounds(0, 0, 370, 690);

        MainPanel.add(AchatCarteNFC, "AchatCarteNFC");

        CheckOut.setLayout(null);

        Lbl4_Titre.setFont(new java.awt.Font("Aharoni", 1, 24)); // NOI18N
        Lbl4_Titre.setForeground(new java.awt.Color(255, 255, 255));
        Lbl4_Titre.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        Lbl4_Titre.setText("Sortir du site");
        CheckOut.add(Lbl4_Titre);
        Lbl4_Titre.setBounds(70, 160, 210, 25);

        Cb4_Avis.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "...", "Not Interesting", "Marginal", "Interesting", "Worthly", "Must Visit" }));
        CheckOut.add(Cb4_Avis);
        Cb4_Avis.setBounds(180, 220, 120, 30);

        Lbl4_Avis.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        Lbl4_Avis.setForeground(new java.awt.Color(255, 255, 255));
        Lbl4_Avis.setText("Votre avis de la visite");
        CheckOut.add(Lbl4_Avis);
        Lbl4_Avis.setBounds(50, 230, 130, 14);

        Btn4_Sortie.setText("Sortir du site");
        Btn4_Sortie.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Btn4_SortieActionPerformed(evt);
            }
        });
        CheckOut.add(Btn4_Sortie);
        Btn4_Sortie.setBounds(110, 310, 140, 30);

        Btn4_Consulter.setText("Consulter la liste de 5 sites");
        Btn4_Consulter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Btn4_ConsulterActionPerformed(evt);
            }
        });
        CheckOut.add(Btn4_Consulter);
        Btn4_Consulter.setBounds(70, 360, 210, 30);

        Lbl4_Vide.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        Lbl4_Vide.setForeground(new java.awt.Color(255, 255, 255));
        Lbl4_Vide.setIcon(new javax.swing.ImageIcon(getClass().getResource("/util/ZSmp22.jpg"))); // NOI18N
        CheckOut.add(Lbl4_Vide);
        Lbl4_Vide.setBounds(0, 0, 360, 690);

        MainPanel.add(CheckOut, "CheckOut");

        Consulter5sites.setLayout(null);

        Lbl_titre.setFont(new java.awt.Font("Aharoni", 0, 24)); // NOI18N
        Lbl_titre.setForeground(new java.awt.Color(255, 255, 255));
        Lbl_titre.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        Lbl_titre.setText("Liste des cinq sites");
        Consulter5sites.add(Lbl_titre);
        Lbl_titre.setBounds(40, 120, 280, 30);

        Lbl5_ButtonBackToPre.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        Lbl5_ButtonBackToPre.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Lbl5_ButtonBackToPreMouseClicked(evt);
            }
        });
        Consulter5sites.add(Lbl5_ButtonBackToPre);
        Lbl5_ButtonBackToPre.setBounds(40, 560, 70, 40);

        Lbl5_BacKToPre.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        Lbl5_BacKToPre.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Lbl5_BacKToPreMouseClicked(evt);
            }
        });
        Consulter5sites.add(Lbl5_BacKToPre);
        Lbl5_BacKToPre.setBounds(150, 570, 20, 30);

        jPanel1.setBackground(new java.awt.Color(0, 102, 204));

        Lbl5_1erSite.setBackground(new java.awt.Color(204, 204, 204));
        Lbl5_1erSite.setForeground(new java.awt.Color(255, 255, 255));
        Lbl5_1erSite.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "1er Site", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 3, 12), new java.awt.Color(255, 255, 255))); // NOI18N

        Lbl5_2emeSite.setForeground(new java.awt.Color(255, 255, 255));
        Lbl5_2emeSite.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "2eme Site", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 3, 12), new java.awt.Color(255, 255, 255))); // NOI18N

        Lbl5_3emeSite.setForeground(new java.awt.Color(255, 255, 255));
        Lbl5_3emeSite.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "3eme Site", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 3, 12), new java.awt.Color(255, 255, 255))); // NOI18N

        Lbl5_4emeSite.setForeground(new java.awt.Color(255, 255, 255));
        Lbl5_4emeSite.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "4eme Site", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 3, 12), new java.awt.Color(255, 255, 255))); // NOI18N

        Lbl5_5emeSite.setForeground(new java.awt.Color(255, 255, 255));
        Lbl5_5emeSite.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "5eme Site", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 3, 12), new java.awt.Color(255, 255, 255))); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(Lbl5_3emeSite, javax.swing.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE)
            .addComponent(Lbl5_2emeSite, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(Lbl5_1erSite, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(Lbl5_5emeSite, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(Lbl5_4emeSite, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Lbl5_1erSite, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Lbl5_2emeSite, javax.swing.GroupLayout.PREFERRED_SIZE, 164, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(Lbl5_3emeSite, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(Lbl5_4emeSite, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Lbl5_5emeSite, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(28, Short.MAX_VALUE))
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {Lbl5_1erSite, Lbl5_2emeSite, Lbl5_3emeSite, Lbl5_4emeSite, Lbl5_5emeSite});

        jScrollPane1.setViewportView(jPanel1);

        Consulter5sites.add(jScrollPane1);
        jScrollPane1.setBounds(40, 150, 280, 410);

        Lbl_Vide.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        Lbl_Vide.setForeground(new java.awt.Color(255, 255, 255));
        Lbl_Vide.setIcon(new javax.swing.ImageIcon(getClass().getResource("/util/ZSmp22.jpg"))); // NOI18N
        Consulter5sites.add(Lbl_Vide);
        Lbl_Vide.setBounds(0, 0, 370, 690);

        MainPanel.add(Consulter5sites, "Consulter5sites");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(MainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 370, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(MainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 715, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void Btn1_NouvClientActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Btn1_NouvClientActionPerformed
        CardLayout card = (CardLayout) MainPanel.getLayout();
        card.show(MainPanel, "AchatCarteNFC");
    }//GEN-LAST:event_Btn1_NouvClientActionPerformed

    private void Btn1_ConnecterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Btn1_ConnecterActionPerformed
        
        if ((this.Tf1_NumTouriste.getText().equals(""))
        		|| (!tct.verifyExistTourist(Short.valueOf(Tf1_NumTouriste.getText())))){
            JOptionPane.showMessageDialog(this," Veuillez entrer un numéro de carte validé","Attention",JOptionPane.WARNING_MESSAGE);
        }
        else
        {
        	Lbl2_NumTourist.setText("Numéro de carte: " + Tf1_NumTouriste.getText());
                CardLayout card = (CardLayout) MainPanel.getLayout();
                tct.setTouristCardNumber(Short.valueOf(Tf1_NumTouriste.getText()));
        	if (!tct.isVisitingSite()) {
        		card.show(MainPanel, "CheckIn");
        	}
        	else {
        		tct.initialiseVisitingSite();
        		card.show(MainPanel, "CheckOut");
        	}
        }
    }//GEN-LAST:event_Btn1_ConnecterActionPerformed

    private void Tf3_NomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Tf3_NomActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_Tf3_NomActionPerformed

    private void Btn3_AcheterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Btn3_AcheterActionPerformed
        // TODO add your handling code here:
        if (this.Tf3_Nom.getText().equals("")){
            JOptionPane.showMessageDialog(this," Veuillez entrer votre nom","Attention",JOptionPane.WARNING_MESSAGE);
        }
        else{
            if (this.Cl3_DateDebut.getDate()==null){
                JOptionPane.showMessageDialog(this,"Veuillez choisir la date début valide de la carte","Attention",JOptionPane.WARNING_MESSAGE);

            }
            else{
                if (this.Cl3_DateFin.getDate()==null){
                    JOptionPane.showMessageDialog(this,"Veuillez choisir la date fin valide de la carte","Attention",JOptionPane.WARNING_MESSAGE);

                }
                else
                {
                    if (this.Cl3_DateDebut.getDate().after(this.Cl3_DateFin.getDate())){
                        JOptionPane.showMessageDialog(this,"Date fin est inférieur à la date début. Veuillez choisir une autre date","Attention",JOptionPane.WARNING_MESSAGE);
                    }
                    else{
                        tct.initServer();
                        short numCarte = tct.purchaseCard(this.Tf3_Nom.getText(),Cl3_DateDebut.getDate(),Cl3_DateFin.getDate());
                   
                        JOptionPane.showMessageDialog(this," Votre carte est bien enregistré. Votre numéro de carte est: "+String.valueOf((int)numCarte),"Message",JOptionPane.INFORMATION_MESSAGE);
                        CardLayout card = (CardLayout) MainPanel.getLayout();
                        card.show(MainPanel, "CheckIn");
                    }
                }
            }
        }
    }//GEN-LAST:event_Btn3_AcheterActionPerformed

    private void Lbl_BackToHomeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Lbl_BackToHomeMouseClicked
        // TODO add your handling code here:
        CardLayout card = (CardLayout) MainPanel.getLayout();
        card.show(MainPanel, "AcceuilTourist");
    }//GEN-LAST:event_Lbl_BackToHomeMouseClicked

    private void Cb2_SiteVisiteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Cb2_SiteVisiteActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_Cb2_SiteVisiteActionPerformed

    private void Btn2_EntrezActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Btn2_EntrezActionPerformed
        if (this.Cb2_SiteVisite.getSelectedItem().toString().equals("...")) {
            JOptionPane.showMessageDialog(this," Veuillez choisir le site à visiter","Attention",JOptionPane.WARNING_MESSAGE);

        }
        else
        {
            //tct.setTouristCardNumber(Short.valueOf(Tf1_NumTouriste.getText()));
            String mess = tct.checkIn((short)Cb2_SiteVisite.getSelectedIndex());
            JOptionPane.showMessageDialog(this,mess,"Message",JOptionPane.INFORMATION_MESSAGE);
            if (mess.equals("Check in OK"))
            {
                CardLayout card = (CardLayout) MainPanel.getLayout();
                card.show(MainPanel, "CheckOut");
            
            }
        }
    }//GEN-LAST:event_Btn2_EntrezActionPerformed

    private void Btn2_ConsulterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Btn2_ConsulterActionPerformed
        TouristeIHM.Lbl5_BacKToPre.setText("checkIn");
        consulterSites();
        CardLayout card = (CardLayout) MainPanel.getLayout();
        card.show(MainPanel, "Consulter5sites");
       
    }//GEN-LAST:event_Btn2_ConsulterActionPerformed

    private void Lbl2_BacktoHomeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Lbl2_BacktoHomeMouseClicked
        // TODO add your handling code here:
        CardLayout card = (CardLayout) MainPanel.getLayout();
        card.show(MainPanel, "AcceuilTourist");
    }//GEN-LAST:event_Lbl2_BacktoHomeMouseClicked

    private void Btn4_SortieActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Btn4_SortieActionPerformed
        // TODO add your handling code here:
        if (this.Cb4_Avis.getSelectedItem().toString().equals("...")) {
            JOptionPane.showMessageDialog(this,"Veuillez donner votre avis avant de sortie du site","Attention",JOptionPane.WARNING_MESSAGE);

        }
        else{
            tct.checkOut(Cb4_Avis.getSelectedIndex());
            CardLayout card = (CardLayout) MainPanel.getLayout();
            card.show(MainPanel, "CheckIn");
        }
    }//GEN-LAST:event_Btn4_SortieActionPerformed

    private void Btn4_ConsulterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Btn4_ConsulterActionPerformed
        CardLayout card = (CardLayout) MainPanel.getLayout();
        card.show(MainPanel, "Consulter5sites");
        TouristeIHM.Lbl5_BacKToPre.setText("checkOut");
        consulterSites();
    }//GEN-LAST:event_Btn4_ConsulterActionPerformed

    private void Lbl5_ButtonBackToPreMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Lbl5_ButtonBackToPreMouseClicked
              
        if (TouristeIHM.Lbl5_BacKToPre.getText().equals("checkIn")){
            CardLayout card = (CardLayout) MainPanel.getLayout();
            card.show(MainPanel, "CheckIn");
        }
        else if (TouristeIHM.Lbl5_BacKToPre.getText().equals("checkOut")){
            CardLayout card = (CardLayout) MainPanel.getLayout();
            card.show(MainPanel, "CheckOut");
        }
    }//GEN-LAST:event_Lbl5_ButtonBackToPreMouseClicked

    private void Lbl5_BacKToPreMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Lbl5_BacKToPreMouseClicked
        // TODO add your handling code here:

        //new Consulter5sites(super);
    }//GEN-LAST:event_Lbl5_BacKToPreMouseClicked

    private void Tf1_NumTouristeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Tf1_NumTouristeActionPerformed
        
    }//GEN-LAST:event_Tf1_NumTouristeActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(TouristeIHM.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(TouristeIHM.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(TouristeIHM.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(TouristeIHM.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new TouristeIHM().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel AcceuilTourist;
    private javax.swing.JPanel AchatCarteNFC;
    private javax.swing.JButton Btn1_Connecter;
    private javax.swing.JButton Btn1_NouvClient;
    private javax.swing.JButton Btn2_Consulter;
    private javax.swing.JButton Btn2_Entrez;
    private javax.swing.JButton Btn3_Acheter;
    private javax.swing.JButton Btn4_Consulter;
    private javax.swing.JButton Btn4_Sortie;
    private javax.swing.JComboBox Cb2_SiteVisite;
    private javax.swing.JComboBox Cb4_Avis;
    private javax.swing.JPanel CheckIn;
    private javax.swing.JPanel CheckOut;
    private com.toedter.calendar.JDateChooser Cl3_DateDebut;
    private com.toedter.calendar.JDateChooser Cl3_DateFin;
    private javax.swing.JPanel Consulter5sites;
    private javax.swing.JLabel Lb2_SiteSouhaite;
    private javax.swing.JLabel Lbl1_DejaCarte;
    private javax.swing.JLabel Lbl1_ImageMain;
    private javax.swing.JLabel Lbl1_NumTouriste;
    private javax.swing.JLabel Lbl1_Titre;
    private javax.swing.JLabel Lbl1_Vide;
    private javax.swing.JLabel Lbl2_BacktoHome;
    public static javax.swing.JLabel Lbl2_NumTourist;
    private javax.swing.JLabel Lbl2_Titre;
    private javax.swing.JLabel Lbl2_Vide;
    private javax.swing.JLabel Lbl3_DateDebut;
    private javax.swing.JLabel Lbl3_DureeValide;
    private javax.swing.JLabel Lbl3_Nom;
    private javax.swing.JLabel Lbl3_Titre;
    private javax.swing.JLabel Lbl3_Vide;
    private javax.swing.JLabel Lbl4_Avis;
    private javax.swing.JLabel Lbl4_Titre;
    private javax.swing.JLabel Lbl4_Vide;
    private javax.swing.JLabel Lbl5_1erSite;
    private javax.swing.JLabel Lbl5_2emeSite;
    private javax.swing.JLabel Lbl5_3emeSite;
    private javax.swing.JLabel Lbl5_4emeSite;
    private javax.swing.JLabel Lbl5_5emeSite;
    public static javax.swing.JLabel Lbl5_BacKToPre;
    private javax.swing.JLabel Lbl5_ButtonBackToPre;
    private javax.swing.JLabel Lbl_BackToHome;
    private javax.swing.JLabel Lbl_Vide;
    private javax.swing.JLabel Lbl_titre;
    private javax.swing.JPanel MainPanel;
    private javax.swing.JTextField Tf1_NumTouriste;
    private javax.swing.JTextField Tf3_Nom;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables
}
